﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NETCore.MailKit.Core;
using System;

namespace XXX.api.Filter
{
    public class ApiLoggingFilterFactory : IFilterFactory
    {
        public bool IsReusable => false;

        public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
        {
            return new ApiLoggingAttribute(
                serviceProvider.GetRequiredService<IEmailService>(),
                serviceProvider.GetRequiredService<ILogger<ApiLoggingAttribute>>(),
                serviceProvider.GetRequiredService<IConfiguration>()
            );
        }
    }
}
